<#assign path = request.getContextPath() />
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>排班编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
             content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="${path}/static/css/font.css">
    <link rel="stylesheet" href="${path}/static/css/css.css">
    <link rel="stylesheet" type="text/css" href="${path}/static/css/xadmin.css"/>
    <script type="text/javascript" src="${path}/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="${path}/static/lib/layui/layui.js"></script>
    <script type="text/javascript" src="${path}/static/js/xadmin.js"></script>
</head>

   <body>
   <div class="x-nav">
       <a href="../index">首页</a>
       <span>&gt;</span>
       <a><cite>排班编辑</cite></a>
   </div>
   <div class="layui-fluid">
       <div class="layui-row layui-col-space15">
           <div class="layui-col-md12">
               <div id="btns" class="btns">
                   <button type="button" class="layui-btn btn" onclick="self.location=document.referrer;">返回</button>
                   <button type="button" class="layui-btn btn" onclick="">保存</button>
                   <button type="button" class="layui-btn btn"
                           onclick="">导入
                   </button>
               </div>
               <div class="layui-card">
                   <div class="layui-card-body">
                       <form class="layui-col-space5">

                           <label for="username" class="layui-form-label">
                               班次名称
                           </label>
                           <div class="layui-input-inline layui-show-xs-block">
                               <input type="text" name="username" id="roster_name" placeholder="" class="layui-input" maxlength="15" value="${data.name}">
                               <input type="text" id="roster_id" value="${data.id}" style="display: none"/>
                           </div>

                           <div class="layui-input-inline layui-show-xs-block">
                               <span>是否跨天</span>
                               <select name="contrller" style="width: 120px;height: 28px;" id="cross">
                                   <#if data.cross == 1 >
                                       <option value="1" selected>是</option>
                                       <option value="2">否</option>
                                   <#else >
                                       <option value="1">是</option>
                                       <option value="2" selected>否</option>
                                   </#if>
                               </select>
                           </div>
                           <#--<div class="layui-form-item">-->
                               <#--<label for="username" class="layui-form-label">-->
                                   <#--临时调班期限-->
                               <#--</label>-->
                               <#--<div class="layui-input-inline">-->
                                   <#--<input class="layui-input" placeholder="选择" name="start" id="start">-->
                               <#--</div>-->
                               <#--<span class="remark">注：到达期限时间后，人员自动调整回原来班组</span>-->
                           <#--</div>-->
                       </form>
                   </div>

                   <div class="layui-card-body layui-table-body layui-table-main">
                       <table class="layui-table layui-form list-table fl" style="width: 250px;">
                           <div class="layui-form-item">
                               <label for="username" class="layui-form-label">人员名单</label>
                           </div>
                           <thead>
                           <!-- <tr>临时调班</tr> -->
                           <tr>
                               <th>
                                   <input type="checkbox" lay-filter="checkall" name="" lay-skin="primary">
                               </th>
                               <th>姓名</th>
                               <th>员工编号</th>
                           </tr>
                           </thead>
                           <tbody>
                                <#if persons??&&(persons?size>0)>
                                    <#list persons as item>
                                        <tr>
                                            <td><input type="checkbox" name="" lay-skin="primary" value="${item.empId}"></td>
                                            <td>${item.empName}</td>
                                            <td>${item.empNo}</td>
                                        </tr>
                                    </#list>
                                </#if>
                           </tbody>
                       </table>
                       <table class="table-list fl" style="width: 80px;margin-top: 30px;">
                           <tr>
                               <td><p class="arr-btn">全部添加 <Span class="font-big">&gt;</Span></p><i class="arr-l"></i>
                               </td>
                           </tr>
                           <tr>
                               <td><p class="arr-btn">添加 <Span class="font-big">&gt;</Span><i class="arr-ls"></i></p>
                               </td>
                           </tr>
                           <tr>
                               <td><p class="arr-btn">全部移除<span class="font-big">&lt;</span><i class="arr-r"></i></p>
                               </td>
                           </tr>
                           <tr>
                               <td><p class="arr-btn">移除<span class="font-big">&lt;</span><i class="arr-rs"></i></p>
                               </td>
                           </tr>
                       </table>
                       <table class="layui-table layui-form list-table fl" style="width: 250px;">
                           <thead>
                           <div class="layui-form-item">
                               <label for="username" class="layui-form-label">其他班次</label>
                               <div class="layui-input-inline">
                                   <input type="text" id="username" name="username" required="" class="layui-input">
                                   <input type="text" id="other_roster_id" style="display: none" value=""/>
                               </div>
                           </div>
                           <tr>
                               <th>
                                   <input type="checkbox" lay-filter="checkall" name="" lay-skin="primary">
                               </th>
                               <th>姓名</th>
                               <th>员工编号</th>
                           </tr>
                           </thead>
                           <tbody>
                           <tr>
                               <td><input type="checkbox" name="" lay-skin="primary"></td>
                               <td>大马猴</td>
                               <td>1000101</td>
                           </tr>
                           <tr>
                               <td><input type="checkbox" name="" lay-skin="primary"></td>
                               <td>大马猴</td>
                               <td>1000101</td>
                           </tr>
                           <tr>
                               <td><input type="checkbox" name="" lay-skin="primary"></td>
                               <td>大马猴</td>
                               <td>1000101</td>
                           </tr>
                           </tbody>
                       </table>
                   </div>
                   <div class="layui-form-item" align="center">
                       <button class="btn" onclick="updateSchedule()">保存</button>
                       <button class=" btn-nobg" lay-filter="reset" lay-submit="reset">重置</button>
                   </div>
               </div>
           </div>
       </div>
   </div>
   <script>
       layui.use(['laydate', 'form'],
               function () {
                   var laydate = layui.laydate;
                   //执行一个laydate实例
                   laydate.render({
                       elem: '#start' //指定元素
                   });
               });

   </script>
   <script>
       layui.use(['laydate', 'form'], function () {
           var laydate = layui.laydate;
           var form = layui.form;
           // 监听全选
           form.on('checkbox(checkall)', function (data) {

               if (data.elem.checked) {
                   $('tbody input').prop('checked', true);
               } else {
                   $('tbody input').prop('checked', false);
               }
               form.render('checkbox');
           });
       });

       layui.use(['laydate', 'form'], function () {
           var laydate = layui.laydate;
           var form = layui.form;
           // 监听全选
           form.on('checkbox(checkall)', function (data) {

               if (data.elem.checked) {
                   $('tbody input').prop('checked', true);
               } else {
                   $('tbody input').prop('checked', false);
               }
               form.render('checkbox');
           });
       });
        //修改排班
       function updateSchedule() {
           var rosterId = $('#roster_id').val();
           var name = $('#roster_name').val();
           var cross = $('#cross').val();
           var addEmpNos = '';
           var removeEmpNos = '';
           var otherRosterId = $('#other_roster_id').val();
           $.ajax({
               url:'/api/employee/schedul/edit',
               type:'POST',
               data:{
                   rosterId: rosterId,
                   name: name,
                   cross: cross,
                   addEmpNos:addEmpNos,
                   removeEmpNos: removeEmpNos,
                   otherRosterId: otherRosterId,
               },
               success: function (res) {
                   console.log(res);
                   if (res.status == 200) {
                       layer.msg("修改成功",{
                           icon:6
                       },function () {
                            location.reload();
                       })
                   } else {
                       layer.msg(res.msg,{
                          icon:2
                       });
                   }
               }
           });
       }

   </script>
   </body>
</html>
